package com.demo.java.controller;

import com.dangdang.ddframe.rdb.sharding.id.generator.IdGenerator;
import com.demo.java.entity.Goods;
import com.demo.java.entity.Tdict;
import com.demo.java.service.GoodsService;
import com.demo.java.service.TdictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/tdict")
public class TdictController {
	@Autowired
	private TdictService tdictService;
	@Autowired
	private IdGenerator idGenerator;

	@GetMapping("/list")
	public List<Tdict> list() {
		return tdictService.findByTdicts();
	}

	@GetMapping("/getById")
	public Tdict getById(Integer id) {
		return tdictService.getById(id);
	}

	@GetMapping("/saveTdict")
	public int saveTdict() {
		Tdict entity = new Tdict();
		entity.setId(idGenerator.generateId().intValue());
		entity.setDictName("男");
		entity.setDictValue("man");
		return tdictService.insertTdict(entity);
	}

}
